package com.xps.charminguser.view.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xps.charminguser.R;
import com.xps.charminguser.utils.SharedPreferencesUtils;
import com.xps.charminguser.view.activity.BillActivity;
import com.xps.charminguser.view.activity.ComleteActivity;
import com.xps.charminguser.view.activity.LoginActivity;
import com.xps.charminguser.view.activity.conductActivity;
import com.xps.charminguser.view.base.BaseFragment;
import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by MI on 2018/1/10.
 */

public class ListFragment extends BaseFragment {
    @BindView(R.id.Layout_SignOut)
    AutoLinearLayout LayoutSignOut;

    Unbinder unbinder;
    @BindView(R.id.all_orderlist)
    AutoLinearLayout allOrderlist;

    @Override
    protected int getRes() {
        return R.layout.fragment_list;
    }

    @Override
    protected void init(View view) {
        unbinder = ButterKnife.bind(this, view);
    }

    @Override
    protected void setData(View view) {

    }

    @Override
    public void onClick(View v) {

    }

    public void hide() {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.hide(this);
        fragmentTransaction.commit();
    }


    @OnClick({R.id.Layout_SignOut, R.id.all_orderlist, R.id.Layout_FinishOrder, R.id.Layour_OrderLing, R.id.Layout_Bill})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.Layout_SignOut:
                Intent intent3 = new Intent(getActivity(), LoginActivity.class);
                intent3.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                SharedPreferencesUtils.putBoolean("isSave", "boolean", false);
                SharedPreferencesUtils.putString("name", "String", "");
                SharedPreferencesUtils.putString("password", "String", "");
                getActivity().startActivity(intent3);
                break;
            case R.id.all_orderlist:
                Intent intent = new Intent(getActivity(), conductActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent);
                break;
            case R.id.Layout_FinishOrder:
                Intent intent1 = new Intent(getActivity(), ComleteActivity.class);
                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent1);
                break;
            case R.id.Layour_OrderLing:
                Intent intent2 = new Intent(getActivity(), ComleteActivity.class);
                intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent2);
                break;
            case R.id.Layout_Bill:
                Intent intent4 = new Intent(getActivity(), BillActivity.class);
                intent4.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent4);
                break;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
